//
//  YeeShopStoreVC.m
//  YeeShopProject
//
//  Created by CoderYee on 2017/3/10.
//  Copyright © 2017年 CoderYee. All rights reserved.
//

#import "YeeShopStoreVC.h"
#import "XRBaseTableViewController.h"
#import "XRCommonSegMentView.h"
#import "YeeStoreHeaderView.h"

@interface YeeShopStoreVC ()<SwipeTableViewDataSource,SwipeTableViewDelegate,XRCommonSegMentViewdelegate>
{
    SwipeTableView       * _swipeTableView;
    XRCommonSegMentView  *_headerBarView;
    YeeStoreHeaderView   *_headerView;
    
}

@end

@implementation YeeShopStoreVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
-(void)addOwnViews
{
    [super addOwnViews];
    
    
    _headerView=[[YeeStoreHeaderView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, kMainShopHeaderHight)];
  
    _headerBarView=[[XRCommonSegMentView alloc] initWithFrame:CGRectMake(0, 0, kMainScreenWidth, 40) titleArray:@[@"店铺首页",@"全部商品",@"热销",@"上新"]];
    [_headerBarView setBackgroundColor:kWhiteColor];
    _headerBarView.delegate =self;
    // init swipetableview
    _swipeTableView = [[SwipeTableView alloc]initWithFrame:self.view.bounds];
    _swipeTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    _swipeTableView.delegate   = self;
    _swipeTableView.dataSource = self;
    _swipeTableView.shouldAdjustContentSize = NO;
    _swipeTableView.swipeHeaderView = _headerView;
    _swipeTableView.swipeHeaderBar = _headerBarView;
    _swipeTableView.alwaysBounceHorizontal=NO;
    _swipeTableView.swipeHeaderTopInset = 0;
    _swipeTableView.swipeHeaderBarScrollDisabled = YES;
    [self.view addSubview:_swipeTableView];

    
}
-(void)addNavbarView
{
    [super addNavbarView];
     self.title=@"店铺";
    
}
-(void)configOwnViews
{
    
    
}
- (NSInteger)numberOfItemsInSwipeTableView:(SwipeTableView *)swipeView
{
    return 4;
}
- (UIScrollView *)swipeTableView:(SwipeTableView *)swipeView viewForItemAtIndex:(NSInteger)index reusingView:(UIScrollView *)view
{
    
    XRBaseTableViewController *Vc=[[XRBaseTableViewController alloc] init];
    [Vc.view setBackgroundColor:xBackgroundColor];
    return Vc.tableView;
}
- (void)swipeTableViewDidScroll:(SwipeTableView *)swipeView
{
    
}
//开始拖拽的时候，当前tableView结束刷新
- (void)swipeTableViewWillBeginDragging:(SwipeTableView *)swipeView
{
//    CustomTableView* tableView=  (CustomTableView*) swipeView.currentItemView;
//    [tableView.mj_header endRefreshing];
//    [tableView.mj_footer endRefreshing];
    
}
- (void)swipeTableViewDidEndDragging:(SwipeTableView *)swipeView willDecelerate:(BOOL)decelerate
{
    
    
}
- (void)swipeTableViewWillBeginDecelerating:(SwipeTableView *)swipeView
{
    
}
- (void)swipeTableViewDidEndScrollingAnimation:(SwipeTableView *)swipeView
{
    
    
}
- (BOOL)swipeTableView:(SwipeTableView *)swipeView shouldSelectItemAtIndex:(NSInteger)index{
    
    return YES;
}
- (void)swipeTableView:(SwipeTableView *)swipeView didSelectItemAtIndex:(NSInteger)index
{
    
    
}
// swipetableView index变化，改变seg的index
- (void)swipeTableViewCurrentItemIndexDidChange:(SwipeTableView *)swipeView
{
    
    [_headerBarView setLineViewFrameWithClickIndex:swipeView.currentItemIndex];

}
// 滚动结束请求数据
- (void)swipeTableViewDidEndDecelerating:(SwipeTableView *)swipeView
{
    //[self getDataAtIndex:swipeView.currentItemIndex];
}
-(void)XRCommonSegMentView:(XRCommonSegMentView *) segmentView ClickatIndex:(NSInteger)index
{
    
    [_swipeTableView scrollToItemAtIndex:index animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
